/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package system.teleport;

import com.aionemu.gameserver.model.Race;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.questEngine.QuestEngine;
import com.aionemu.gameserver.questEngine.handlers.QuestHandler;
import com.aionemu.gameserver.questEngine.model.QuestEnv;
import com.aionemu.gameserver.services.TeleportService;

/**
 * @author Mr. Poke
 *
 */
public class _1000AbyssGate extends QuestHandler
{
	private final static int	questId	= -1000;

	public static void main(String[] args)
	{
		QuestEngine.getInstance().addQuestHandler(new _1000AbyssGate());
	}

	/**
	 * @param questId
	 */
	public _1000AbyssGate()
	{
		super(questId);
		qe.setNpcQuestData(730059).addOnTalkEvent(questId); //Verteron
		qe.setNpcQuestData(730060).addOnTalkEvent(questId); //Eltnen
		qe.setNpcQuestData(700360).addOnTalkEvent(questId); //Heiron
		qe.setNpcQuestData(730062).addOnTalkEvent(questId); //Altgard
		qe.setNpcQuestData(730063).addOnTalkEvent(questId); //Morheim
		qe.setNpcQuestData(730064).addOnTalkEvent(questId); //Beluslan
	}

	@Override
	public boolean onDialogEvent(QuestEnv env)
	{
		final Player player = env.getPlayer();
		//TODO System message ?
		if (player.getLevel() < 25)
			return true;
		int npcId = env.getVisibleObject().getNpcId();
		switch (npcId)
		{
			//ASMODIAN
			case 730062:
			case 730063:
			case 730064:
				//TODO System meassage
				if (player.getRace() != Race.ASMODIANS)
					return true;
				new NpcUseAction(player, env.getVisibleObject())
				{
					@Override
					protected void end()
					{
						super.end();
						TeleportService.teleportTo(player, 400010000, 1078, 2839, 1636, 0);
					}
				};
			break;
			//ELYOS
			case 730059:
			case 730060:
			case 700360:
				//TODO System meassage
				if (player.getRace() != Race.ELYOS)
					return true;
				new NpcUseAction(player, env.getVisibleObject())
				{
					@Override
					protected void end()
					{
						super.end();
						TeleportService.teleportTo(player, 400010000, 2867, 1034, 1528, 0);
					}
				};
		}
		return true;
	}
}
